package com.leyou.cart.listener;

import com.leyou.cart.service.CartService;
import com.leyou.common.constants.MQConstants;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 短信监听类
 */
@Component
public class CartListener {
    @Autowired
    private CartService cartService;


    /**
     * 删除购物车数据
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = MQConstants.Queue.ORDER_CART_QUEUE),
            exchange = @Exchange(name = MQConstants.Exchange.ORDER_EXCHANGE_NAME, type = ExchangeTypes.TOPIC),
            key = MQConstants.RoutingKey.ORDER_CART_KEY
    ))
    public void deleteOrderCart(Map<String,Object> cartMap) {
        //删除购物车数据
        cartService.deleteOrderCart(cartMap);
    }

}
